using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public enum Supply
{
    None,
    Banana,
    Bread,
    Carrot,
    Fish,
    PrimaryMedical,
    MiddleMedical,
    SeniorMedical,
    SuperMedical,
    Sword
}
public class ShinnyItem : MonoBehaviour {

    [SerializeField] private Supply supply = Supply.None;

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.GetComponent<PlayerController>())
        {
            if(supply == Supply.Sword)
            {
                PlayerController.GetInstance().UpgradeWeapon();
                Destroy(gameObject);
                return;
            }
            //加入背包
            PlayerBagManager.GetInstance().IncreaseItem(supply.ToString());
            //补充体力
            GameManager.GetInstance().IncreasePlayerStrength(10f);
            Destroy(gameObject);
        }
    }

    void Update()
    {
        if(GameObject.FindGameObjectWithTag("Enemy") == null)
        {
            if(GameManager.GetInstance().playerWeapon == PlayerWeapon.UpgradeWeapon)
            {
                return;
            }
            if (supply == Supply.Sword)
            {
                GetComponent<SpriteRenderer>().enabled = true;
                GetComponent<BoxCollider2D>().enabled = true;
            }
        }
    }

}
